var Login=function () {

    return{
        init:function () {
            $('#loginForm').bootstrapValidator({
                message: '该值无效',
                trigger: 'blur keyup',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    /*验证：规则*/
                    username: {
                        validators: {
                            notEmpty: {
                                message: '用户名不能为空'
                            }
                        }
                    },
                    password: {
                        validators: {
                            notEmpty: {
                                message: '密码不能为空'
                            }
                        }
                    }
                }
            })
        },
        login:function(){
            $('#loginForm').bootstrapValidator('validate');
            var bootstrapValidator = $("#loginForm").data('bootstrapValidator');
            if(bootstrapValidator.isValid()){
                $('#loginForm').submit();
            }
        },
        restForm:function () {
            $('#loginForm')[0].reset();
            //$('#loginForm').bootstrapValidator('destroy');
            //$("#loginForm").data('bootstrapValidator',null);
        }
    }
}();